import tkinter as tk
# 导入消息盒子的控件
from tkinter import messagebox

class MyWindow():
    def __init__(self,app):
        self.app = app
        self.app.title("Hello tkinter!")
        self.app.geometry("%dx%d+%d+%d" % (200,200,200,200))

        self.label = tk.Label(self.app,text="一下内容是按钮",font=('黑体',20))
        # pack 一种放置组件的方式，顺序放置
        self.label.pack()

        # command 绑定按键的事件方式
        self.button = tk.Button(self.app,text="按钮",font=('华文彩云',20),command=self.onBtnClick)
        self.button.pack()

    # 定义当按钮点击后，触发的事件函数
    def onBtnClick(self):
        messagebox.showinfo("消息","按钮被点击了")

if __name__ == '__main__':
    app = tk.Tk()
    window = MyWindow(app)
    app.mainloop()